package cn.vcjf.weapp.mpGenerator;

import cn.vcjf.weapp.api.active.entity.GoodsActive;
import cn.vcjf.weapp.common.TableAlias;
import cn.vcjf.weapp.common.util.QiniuUploadFile;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotations.TableName;

import java.io.BufferedReader;
import java.io.FileReader;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @Auther: zhengzihang
 * @Date: 2018/7/18 17:31
 * @Description:
 */
public class CarBrand {

	public static void main(String[] args) throws NoSuchFieldException {
		Class clazz = GoodsActive.class;
		Annotation[] annotations = clazz.getAnnotations();
		for (Annotation annotation : annotations) {
			if(annotation instanceof TableName){
				annotation = (TableName)annotation;
			}
			System.out.println(annotation.toString());
		}
		/*
		Field goodsGroupId = clazz.getDeclaredField("goodsGroupId");
		boolean annotationPresent = goodsGroupId.isAnnotationPresent(TableAlias.class);
		System.out.println(annotationPresent);
		TableAlias annotation = goodsGroupId.getAnnotation(TableAlias.class);
		System.out.println(annotation.value());*/

	}

	public static void main2(String[] args) throws Exception {

		FileReader reader=new FileReader("D://Downloads/cars.json");
		BufferedReader bf=new BufferedReader(reader);
		StringBuffer buffer = new StringBuffer(614400);
		String s = null;
		while ((s = bf.readLine())!=null){
			buffer.append(s);
		}
		JSONObject object = JSON.parseObject(buffer.toString());
		Set<Map.Entry<String, Object>> entries = object.entrySet();

		for(Map.Entry<String, Object> entry: entries){
			System.out.println("---"+entry.getKey());
			Object value = entry.getValue();
			List<Map<String,String>> list = (List<Map<String,String>>) value;
			for(Map<String,String> m:list){
				String name = m.get("name");
				String img = m.get("img");
				//  data:image/png;base64,
				System.out.println("name="+name+"\t,img="+img);
				String s1 = QiniuUploadFile.put64(img);

				return;
			}

		}
	}
}
